/*
 * @Description:4
 * @version:
 * @Author: 尹鹏孝
 * @Date: 2023-03-07 11:44:16
 * @LastEditors: 尹鹏孝
 * @LastEditTime: 2023-03-08 08:49:52
 */
export default{
    install(app,options){
          let doc = document.querySelector("#versions")
        app.config.globalProperties.$loading=()=>{
              let title = options.title
            function show() {
                    if (doc) {
                        doc.style.display = 'block'
                    } else {
                        doc = `<div style="display:flex;padding:20px;background:#000;border-radius:10px;font-size:20px;display:block">${title}</div>`;
                        let tg=document.createElement("div")
                        tg.innerHTML=doc;
                        tg.id = "versions"
                        tg.style = `background:#fff;position:fixed;z-index:999;height:100vh;width:100vw;top: 0;left: 0;bottom: 0;right: 0;`
                         var fragment = document.createDocumentFragment();

                         fragment.appendChild(tg)
                         document.body.appendChild(fragment);
                    }
                }
             function   hide() {
                    if (doc) {
                        doc.style.display = 'hide'
                    } else {
                        doc = `<div style="display:flex;padding:20px;background:#000;border-radius:10px;font-size:20px;display:hide">${title}</div>`;
                         let tg = document.createElement("div")
                         tg.style = "background:#fff;position:fixed;z-index:999;height:100vh;width:100vw;top: 0;left: 0;bottom: 0;right: 0;"
                         tg.innerHTML = doc;
                          tg.id = "versions"
                         var fragment = document.createDocumentFragment();

                         fragment.appendChild(tg)
                         document.body.appendChild(fragment);
                    }
                }
            return {
                  show,
                  hide,
            }

        }
        // const version = Number(app.version.split(".")[0]);
        // if(version<3){
        //     console.warn("这个插件需要vue3");
        // }else{
        //     let title = options.title
        //     let doc = document.querySelector("#versions")
        //     if (doc) {
        //         doc.style.display = option.show
        //     }else{
        //          doc = `<div id="versions" style="background:#fff;position:fixed;z-index:999;height:100vh;width:100vw"><div style="display:flex;padding:20px;background:#000;border-radius:10px;font-size:20px;display:${option.show}">${title}</div> </div>`;
        //          document.body.append(doc);
        //     }

        // }
    }
}